import React from 'react';
import {
  View,
  TouchableOpacity,
  Text,
  ScrollView,
  Image
} from 'react-native';

import BasePage from '../common/BasePage';
import CommonStyles from '../../common/CommonStyles';
import Config from '../../config';
import SizeUtils from '../../common/SizeUtils';
import Constants from '../../common/Constants';


var enter_world_config=[{icon:require("../../../resource/images/heart/aiqingshi/17.png"),title:"心理评测"},
{icon:require("../../../resource/images/heart/aiqingshi/15.png"),title:"自助服务"},
{icon:require("../../../resource/images/heart/aiqingshi/16.png"),title:"我要分享"}]
export default class HeartBaseContentPage extends BasePage {
  constructor(props) {
    super(props);
  }

  render(){
  	 return (
      <View style={{flex:1, height:SizeUtils.getWindowSize().height - Config.tabBarTop}}>
        <View style={{flexDirection: "column"}}>
          {this._renderImage()}
          {this._renderTab()}
          {this._renderContent()}
          {this._renderBack()}
        </View>
      </View>
    )
  }

  _renderImage(){
    return ( <Image source={this._getBackImage()}
            style={{width:SizeUtils.getWindowSize().width,
              height:SizeUtils.translateDesignWidthToCode(315)}}
            />)
  }

  _renderBack(){
    return (<View style={{width:SizeUtils.translateDesignWidthToCode(100),position:"absolute"
    ,left:SizeUtils.translateDesignWidthToCode(40),paddingTop:Config.tabBarTop}}>
            <TouchableOpacity onPress={this.goBack.bind(this)} style={{width:SizeUtils.translateDesignWidthToCode(100)}}>
               <Image source={require("../../../resource/images/common/Back-icon2.png")}
                style={{width:SizeUtils.translateDesignWidthToCode(20), height:SizeUtils.translateDesignWidthToCode(35)}}/>
        </TouchableOpacity></View>)
  }

  _renderTab(){
    return (<View style = {{flexDirection: 'row', justifyContent: 'space-around',
      width:SizeUtils.getWindowSize().width,height:SizeUtils.translateDesignHeightToCode(122)}}>
        </View>);
  }

  _getTabButton(item,index) {
    return(
      <TouchableOpacity
        onPress = {() => this._onPressPageBtn(index)}
        style={{flexDirection: 'column',alignItems: 'center'}}>
        <Image source={item.icon} style={{width:SizeUtils.translateDesignWidthToCode(item.width),
            height:SizeUtils.translateDesignWidthToCode(item.height)}}/>
        <Text style={{color: "#666666",marginTop:SizeUtils.translateFontSizeToCode(20),backgroundColor:"#00000000",
            textAlign:"center", fontSize:SizeUtils.translateFontSizeToCode(24)}}>{item.title}
        </Text>
      </TouchableOpacity>
    )
  }


  // _getRendList(){
  //   return (<View></View>)
  // }

  _renderItem(index) {
    return(
      <TouchableOpacity style={{}}
        onPress={() => this._onPressItem(index)}>
        <View style={{flexDirection:"row", alignItems:"center",marginBottom:SizeUtils.translateDesignHeightToCode(30)}}>
          <Image source={this._getItemData(index).image} style={{}}/>
          <Text style={{position:"absolute",left: SizeUtils.translateFontSizeToCode(50),top: SizeUtils.translateFontSizeToCode(50),fontSize:SizeUtils.translateFontSizeToCode(34),color:"#fff"}}>{this._getItemData(index).name}</Text>
           <Text style={{position:"absolute",left: SizeUtils.translateFontSizeToCode(50),bottom: SizeUtils.translateFontSizeToCode(80), fontSize:SizeUtils.translateFontSizeToCode(24),
            color:"#fff"}}>{this._getItemData(index).desc}</Text>
        </View>
      </TouchableOpacity>
    )
  }

    _onPressItem(index) {
      // this.gotoPage(Config.pages.news_content, data);
    	console.log("_onPressItem"+index);
  }

  _getItemMarginTop(index) {
    let top = 0;
    if(index == 3) {
      top = 60;
    }
    return SizeUtils.translateDesignHeightToCode(top);
  }

  _getItemHeight(index) {
    let height = 118;
    if(index == 3) {
      height = 170;
    }
    return SizeUtils.translateDesignHeightToCode(height);
  }

  _getItemText(index) {
    return TEXT[index];
  }

  _getItemData(index) {
    return heart_config[index];
  }
}
